//
//  CustomButton.m
//  DEMO
//
//  Created by J on 16/3/4.
//  Copyright © 2016年 J. All rights reserved.
//

#import "CustomButton.h"
#import "UIView+Extension.h"
@implementation CustomButton

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setTitleColor:[UIColor purpleColor] forState:UIControlStateHighlighted];
        /*
        self.titleLabel.textColor//不能这样设置 因为 需要一个状态
//        self.imageView.image
         */
        self.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return self;
}

//- (CGRect)imageRectForContentRect:(CGRect)contentRect{//默认情况时bounds 如果设置self.contentEdgeInsets 就是实际的内容显示区域
//    return CGRectMake(0, 0, 100, 50);
//    
//}
//
//- (CGRect)titleRectForContentRect:(CGRect)contentRect{
//    return CGRectMake(0, 50, 100, 50);
//
//}
//



//等于上面2个方法的合集
- (void)layoutSubviews{
    [super layoutSubviews];
    self.imageView.frame = CGRectMake(0, 0, self.width, self.height*0.5);
    self.titleLabel.frame = CGRectMake(0, self.height*0.5, self.width, self.height*0.5);
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    
}

@end
